<?php
/**
 * 商户
 * User: chen guang
 * Date: 2017/9/29 9:00
 *
 */

namespace app\admin\Controller;


use think\Db;

class Web extends Common{
	
	/*
	*	构造函数
	*/
	function __construct(){
		parent::__construct();

	}

    /**
     * 网页
     */
    public function web_index(){
    	$type = input('type');
    	$content = input('content');

    	$where['type'] = $type;
    	$web_result = db('web')->where($where)->find();

		if(request()->isPost()){
			$data['content'] = $content;

			if(empty($web_result)){
				$data['type'] = $type;
				db('web')->insert($data);
			}else{
				db('web')->where($where)->update($data);
			}

			$this->redirect(url('Web/web_index',array('type'=>$type)));
		}

		switch ($type) {
			case '1':
				$title = '关于我们';
				break;
			case '2':
				$title = '用户协议';
				break;
			case '3':
				$title = '版权信息';
				break;
			case '4':
				$title = '商户合作';
				break;
			case '5':
				$title = '软件介绍';	
				break;
			case '6':
				$title = '食圈1';	
				break;
			case '7':
				$title = '食圈2';	
				break;
			case '8':
				$title = '食圈3';	
				break;
			case '9':
				$title = '商城1';	
				break;
			case '10':
				$title = '商城2';
				break;
			case '11':
				$title = '商城3';		
				break;
		}

		$this->assign('web_result',$web_result);
		$this->assign('type',$type);
		$this->assign('title',$title);
        return $this->fetch();
    }



}